#set(seoTitle="登录 JFinal 社区")
#@layout()
#define main()
<div class="col" style="margin-bottom: 20px;">
	<div class="jf-panel">
		<div class="jf-panel-header">
			<h1 class="jf-login-title">登录</h1>
		</div>
	 	
		<div class="jf-panel-body mt15" style="width: 500px;margin:30px auto;">
		
			<!-- 内容区域  start-->
			<form id="login_form" action="/login/doLogin?returnUrl=#(returnUrl)" method="post">
				<div class="form-group row mb-4">
					<label for="userName" class="col-sm-2 col-form-label  col-form-label-lg">邮箱</label>
				    <div class="col-sm-10">
						<input type="email" class="form-control form-control-lg" id="userName" name="userName" placeholder="请输入邮箱地址">
				    </div>
				</div>
				<div class="form-group row mb-4">
					<label for="password" class="col-sm-2 col-form-label  col-form-label-lg">密码</label>
				    <div class="col-sm-10">
						<input type="password" autocomplete="off" class="form-control form-control-lg" id="password" name="password" placeholder="请输入密码">
				    </div>
				</div>
				<div class="form-group row mb-4">
					<label class="col-sm-2  col-form-label-lg">
						<img title="点击刷新" onclick="updateCaptcha(this,'captchaInput')" id="captchaImg" class="jf-login-captcha" src="/login/captcha"/>
					</label>
				    <div class="col-sm-10">
						<input type="text" autocomplete="off" class="form-control  form-control-lg" id="captchaInput" name="captcha" placeholder="请输入验证码">
				    </div>
				</div>
				
				  <div class="form-group row">
				    <div class="col-10 offset-2">
				      <div class="form-check">
				        <input class="form-check-input" name="keepLogin" type="checkbox" id="keepLogin" value='1' checked>
				        <label class="form-check-label" for="keepLogin">
				          	保持登录<span class="text-danger ml-2">(勿在公用电脑上使用)</span>
				        </label>
				      </div>
				    </div>
				  </div>
				  
				  <div class="form-group row">
				    <div class="col-12 text-right">
				      <button type="submit" class="btn btn-primary btn-lg" style="padding-left:20px;padding-right:20px;">登 录</button>
				    </div>
				  </div>
			</form>
			
			<div class="jf-login-links">
				没有账号<a href="/reg" onclick="appendReturnUrl(this)">现在注册</a>
				<a class="ml-2" href="/login/forgetPassword">忘记密码？</a>
				<a class="ml-2"  href="/reg/notActivated">还没激活？</a>
			</div>
			<!-- 内容区域  end-->
		</div>
	</div>
</div>
#end

#define js()
	<script type="text/javascript" src="/assets/jquery_form/jquery.form.min.js"></script>
	<script type="text/javascript" src="/assets/layer/layer/layer.js"></script>

	<script type="text/javascript">
		
		var captchaImg = $("#captchaImg");
		var captchaInputId = "captchaInput";
		
		$(document).ready(function() {
			$("#login_form").ajaxForm({
				dataType: "json"
				, beforeSubmit: function(formData, jqForm, options) {
					// 表单提交之前回调
				}
				, success: function(ret) {
					if(ret.state == "ok") {
						location.href = ret.returnUrl;
					} else {
						layer.msg(ret.msg, {
									shift: 6
									, shade: 0.3
									, time: 7000			// 0 为不自动关闭窗口
									, offset: "165px"
									, closeBtn: 1
									, shadeClose: true
								} , function() {
									updateCaptcha(captchaImg, captchaInputId);
								}
						);
					}
				}
				, error: function(ret) { }              // ret.status != 200 时回调
				, complete: function(ret) { }       // 无论是 success 还是 error，最终都会被回调
			});
		});
	</script>
#end